//Erstellt von Moritz Liepe
package main.editor;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;

public class SetTargetHandler extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {

		String message = "";
			
		VOSEditor vosEditor;
		IEditorPart page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor();
		if((page != null) && (page instanceof VOSEditor))
		{
			vosEditor = (VOSEditor)page;
			message = vosEditor.getModuleEditor().setTarget();
		}
		if (!message.equalsIgnoreCase("Connection done!")){
			Shell shell = HandlerUtil.getActiveWorkbenchWindow(event).getShell();  
			String dialogBoxTitle = "Connection failed";  
			MessageDialog.openInformation(shell, dialogBoxTitle, message); 
		}
		

		return null;
	}

}
